﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SalesByCategoryReport.aspx.cs" Inherits="ReportPages_AlphabeticalListOfProductsReport" %>

<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, 
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Sales By Category Report</title>
    <style type="text/css">
        .style1
        {
            width: 84px;
        }
        .style2
        {
            width: 88px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

        <a href="../Default.aspx">Home</a><br /><br />    
        <table style="width:100%;">
            <tr>
                <td class="style1">
                    CategoryId:</td>
                <td class="style2">
                    <asp:TextBox ID="categoryIdTextBox" runat="server" Width="83px"></asp:TextBox>
                </td>
                <td>
                    <asp:Button ID="Button1" runat="server" Text="Refresh" Width="111px" 
                        onclick="Button1_Click" />
                </td>
            </tr>
        </table>
        <br /><br />     
    </div>
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" 
            Font-Size="8pt" Height="659px" Width="699px">
            <LocalReport ReportPath="Reports\SalesByCategoryReport.rdlc">
                <DataSources>
                    <rsweb:ReportDataSource DataSourceId="AccessDataSource1" 
                        Name="SimpleReportsDataSet_SalesByCategory" />
                </DataSources>
            </LocalReport>
        </rsweb:ReportViewer>
        <asp:AccessDataSource ID="AccessDataSource1" runat="server" 
            DataFile="~/App_Data/NorthwindNET.mdb" 
            DeleteCommand="DELETE FROM `Shipper` WHERE `ID` = ?" 
            InsertCommand="INSERT INTO `Shipper` (`ID`, `Name`, `Phone`) VALUES (?, ?, ?)" 
            SelectCommand="SELECT Product.CategoryID, Category.Name AS CategoryName, Product.Name AS ProductName, SUM(OrderDetailsExtended.ExtendedPrice) AS ProductSales FROM (Category INNER JOIN (((SELECT OrderID, ProductID, ProductName, UnitPrice, Quantity, Discount, ExtendedPrice FROM udf_OrderDetailsExtended) OrderDetailsExtended INNER JOIN [Order] ON OrderDetailsExtended.OrderID = [Order].ID) INNER JOIN Product ON OrderDetailsExtended.ProductID = Product.ID) ON Category.ID = Product.CategoryID) WHERE (prmCategoryID = -1) OR (Category.ID = prmCategoryId) GROUP BY Product.CategoryID, Category.Name, Product.Name ORDER BY Category.Name" 
            
            
            UpdateCommand="UPDATE `Shipper` SET `Name` = ?, `Phone` = ? WHERE `ID` = ?">
            <SelectParameters>
                <asp:ControlParameter ControlID="categoryIdTextBox" DefaultValue="-1" 
                    Name="prmCategoryId" PropertyName="Text" Type="Int32" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="ID" Type="Int32" />
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Phone" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Phone" Type="String" />
                <asp:Parameter Name="ID" Type="Int32" />
            </UpdateParameters>
        </asp:AccessDataSource>
    </form>
</body>
</html>
